﻿Type=StaticCode
Version=5.8
ModulesStructureVersion=1
B4A=true
@EndOfDesignText@
'Code module
'Subs in this code module will be accessible from all modules.
Sub Process_Globals
	'These global variables will be declared once when the application starts.
	'These variables can be accessed from all modules.
	Public uil,uilnocache As UniversalImageLoader
	Public fa As FontAwesome
	Private lstShareSdkCfg As List
'	Dim ri As RoundImage
	
'	Private imgEff As RSImageEffects
'	Private riopt As RoundImage
	Public ActiveBitmap As Bitmap=LoadBitmap(File.DirAssets,"indicator_active.png")
	Public InactiveBitmap As Bitmap=LoadBitmap(File.DirAssets,"indicator_inactive.png")
	Public bmpSexMan As Bitmap=LoadBitmap(File.DirAssets,"sexnan.png")
	Public bmpSexWoman As Bitmap=LoadBitmap(File.DirAssets,"sexnv.png")
	'模型
	Type Subject(name As String,img As String,id As String)
	Type Teacher(ID As String,realname As String,nickname As String,sexMen As Boolean,startPrice As String,teacheAge As Int,rateNum As String,ratePercent As String,distence As String,adWords As String,headimg As String,stunum As String,mobile As String)
	Type wvUrl(Url As String,allowZoom As Boolean,title As String)
	Type myInfo(jpush_pwd As String,qqid As String,wxid As String,paypwd As String,headimg As String,sex As String,city As String,usertel As String,age As Int,uid As Int,commit As String,address As String,grade As String,jwd As String,cookie As String,nickname As String,school As String,yue As String,ordNum As Int,yhqNum As Int,favTeacherNum  As Int)
	Type yhq(yhqname As String,yhdid As Int,money As String,starttime As String,endtime As String,uselimit As String,withLimit As Boolean)
	Type kcItem(hours As String,kctype As String,kctitle As String,kcid As String,price_lssm As String,price_xssm As String,price_xsdz As String,trdid As String,addr As String,tecname As String,tecImg As String,time As String,status As String,sex As String,kemu As String,grade As String,shangmenfangshi As String)
	Type OrderItem(ordersn As String,ordstatus As String,price As String,ordid As Int,seller As Teacher,itemname As String,ordTime As String)
	Type JqOrderItem(ordersn As String,ordstatus As String,price As String,ordid As Int,seller As Teacher,itemname As String,ordTime As String)
	Type CaiwuItem(title As String,id As String,apitype As String,amount As String,status As String,time As String)
	Type rateItem(id As Int,teachheadimg As String,teachname As String,ratetype As String,kcname As String,ordTime As String,content As String,contentTime As String)
	Type payItem(pid As String,title As String,money As String,noinpay As Boolean)
	'图片查看调用对象
	Type pvObj(Url As String,title As String)
	Type Student(name As String,age As Int,grade As String,school As String,img As String,keshi As Int,city As String)
	Type Fudaoban(name As String,finish As Boolean)
	Type netRes(nCode As Int,sData As String,obj As Object) '网络请求返回
	'lst里是市
	Type CityShen(name As String,lst As List)
	'lst里是区
	Type CityShi(name As String,lst As List)
	Private CityJsp As JSONParser=Null
	Private CityCurShen As CityShen
	'锦旗模型
	Type Jinqi(sendby As Student,jqType As Int,evalStr As String,sDate As String,price As String)
	'常量
	Private gf As GalleryFinal
	Public S_JPUSH_PASS="kp123456",SHARE_APPKEY As String="110c6550f3e1f",BUGLY_APPID As String="900029248"
	Public S_GalleryFinalTheme As Object=gf.GREEN
	Public S_SHARE=1,S_COMPARE_PRICE=2,S_NEWS=3,S_FEEDBACK=4,S_SETTING=5,S_CLIENTPHONE=6,S_PERSONALINFO=7,S_MYFAVTEACHER=8,S_KECHENGRATE=9,S_LOGOUT=10,S_NUMS_PER_PAGE=20 As Int
	Public S_APPNAME="靠谱家教",S_SUBJECTS="subjects",S_PAIXU_FINDTEACHER="paixufind",S_NIANJI_FINDTEACHER="grade",S_CITYLIST="citys",S_SKFS As String
	'webserver config
	'Public S_APP_API As String="http://kpjj.xjwanwei.com/"
	Public S_APP_API As String="http://192.168.1.66/"
	Public S_WEBSITE As String="http://www.kaopuedu.com"
	Type apiIndex(REQNEWSLIST As Int,REQHELPYOUFINDTEACHER As Int,REQALLFUDAOBAN  As Int,REQUNCOMPLETEKC As Int,REQBINDTHIRDACCOUNT As Int,REQLOGINBYTHIRD As Int,REQCITYLIST As Int,REQTEACHERLIST As Int,REQEVALLISTBYTEACHER As Int,SUBJINQIORDER As Int,REQALLKCLISTBYTEACHER As Int,POSTRATE As Int,REQORDERREFUND As Int,REQORDDETAIL As Int,REQCHARGE1 As Int,REQCHARGE2 As Int,REQJQLST As Int,REQUNRATENUM  As Int,REQPAYPWDCHG As Int,REQINAPPPAY As Int,SUBMITORDER,REQMYRATE As Int,REQCAIWULST As Int,REQORDLST As Int,REQKECHENLIST As Int,ADDFAVTEACHER  As Int,MODIFYPASS As Int,MODIFYMYINFO As Int,UPLOADIMG As Int,REQJINQI As Int,ADDYHQ As Int,APPBANNER As Int,KEMU  As Int,MSTJ As Int,LOGIN As Int,LOGOUT As Int,GETYHQ As Int,REFUSHMYINFO As Int,MYFAVTEACHER As Int,DELFAVTEACHER As Int,SEARCHTEACHER As Int,LOGINWITHSMS As Int,REQSMS As Int,REGISTER As Int,REQTEACHERDETAIL As Int,RESETPASSWORD As Int,FEEDBACK As Int)
	Dim apiIdx As apiIndex
	apiIdx.Initialize
	apiIdx.APPBANNER=0
	apiIdx.KEMU=1
	apiIdx.MSTJ=2
	apiIdx.LOGIN=3
	apiIdx.LOGOUT=4
	apiIdx.GETYHQ=5
	apiIdx.REFUSHMYINFO=6
	apiIdx.MYFAVTEACHER=7
	apiIdx.DELFAVTEACHER=8
	apiIdx.SEARCHTEACHER=9
	apiIdx.LOGINWITHSMS=10
	apiIdx.REQSMS=11
	apiIdx.REGISTER=12
	apiIdx.REQTEACHERDETAIL=13
	apiIdx.RESETPASSWORD=14
	apiIdx.FEEDBACK=15
	apiIdx.ADDYHQ=16
	apiIdx.REQJINQI=17
	apiIdx.UPLOADIMG=18
	apiIdx.MODIFYMYINFO=19
	apiIdx.MODIFYPASS=20
	apiIdx.ADDFAVTEACHER=21
	apiIdx.REQKECHENLIST=22
	apiIdx.REQORDLST=23
	apiIdx.REQCAIWULST=24
	apiIdx.REQMYRATE=25
	apiIdx.SUBMITORDER=26
	apiIdx.REQINAPPPAY=27
	apiIdx.REQPAYPWDCHG=28
	apiIdx.REQUNRATENUM=29
	apiIdx.REQJQLST=30
	apiIdx.REQCHARGE1=31
	apiIdx.REQCHARGE2=32
	apiIdx.REQORDDETAIL=33
	apiIdx.REQORDERREFUND=34
	apiIdx.POSTRATE=35
	apiIdx.REQALLKCLISTBYTEACHER=36
	apiIdx.SUBJINQIORDER=37
	apiIdx.REQEVALLISTBYTEACHER=38
	apiIdx.REQTEACHERlist=39
	apiIdx.REQCITYLIST=40
	apiIdx.REQLOGINBYTHIRD=41
	apiIdx.REQBINDTHIRDACCOUNT=42
	apiIdx.REQUNCOMPLETEKC=43
	apiIdx.REQALLFUDAOBAN=44
	apiIdx.REQHELPYOUFINDTEACHER=45
	apiIdx.REQNEWSLIST=46
	'ulv
	Public N_COLOR_ORANGE=0xFFFF6A00,N_COLOR_TITLE=0xFF009688 As Int,N_ULVMEMCACHE=15 As Int,N_ULVDISKCACHE=35 As Int,S_ULVCACHEDIR=File.DirInternalCache As String
	Public S_CLIENTPHONENUMBER="09916664610" As String
	
	'test
	Public S_TESTTEACHERHEADER As String="http://app.modao.cc/uploads/images/2268885/raw_1454036696.jpeg",S_TESTMYHEADER As String="http://app.modao.cc/uploads/images/2268884/raw_1454036696.jpeg"
	Public mChe As Map
	'mChe.Initialize
	Public su As StringUtils
End Sub
Public Sub urlencode(str As String) As String
	Return su.EncodeUrl(str,"UTF8")
End Sub
public Sub urldecode(str As String) As String
	Return su.DecodeUrl(str,"UTF8")
End Sub
Sub SetPadding(v As View, Left As Int, Top As Int, Right As Int, Bottom As Int)
	 Dim jo As JavaObject = v
	 jo.RunMethod("setPadding", Array As Object(Left, Top, Right, Bottom))
End Sub
'Acceptable URIs examples
'"http://site.com/image.png" // from Web
'"file:///mnt/sdcard/image.png" // from SD card
'"file:///mnt/sdcard/video.mp4" // from SD card (video thumbnail)
'"content://media/external/images/media/13" // from content provider
'"content://media/external/video/media/13" // from content provider (video thumbnail)
'"assets://image.png" // from assets
'"drawable://" + R.drawable.img // from drawables (non-9patch images)
Sub loadimg (imgurl As String,v As View)
	uil.loadimg(imgurl,v)
End Sub
Sub loadimg_nocache (imgurl As String,v As View)
	uilnocache.loadimg(imgurl,v)
End Sub
'统一入口便于后期可能的修改
public Sub T(msg As String)
	ToastMessageShow(msg,False)
End Sub
Public Sub showProgress(msg As String)
	ProgressDialogShow(msg)
End Sub
Public Sub L(msg As String)
	Log(msg)
End Sub
public Sub TL(msg As String)
	ToastMessageShow(msg,False)
	Log(msg)
End Sub
public Sub CreateCustomPanel(act As Panel,w As Int,h As Int) As Panel
	Dim p As Panel
	p.Initialize("")
	act.AddView(p,0,0,w,h)
	p.RemoveView
	Return p
End Sub
'Public Sub setImageUriRIV(riv As View,uri As String)
'	Dim jo As JavaObject
'	jo=riv
'	jo.RunMethod("setImageURI",Array As Object(ParseUri(uri)))
'End Sub

'fitXY=1,center=5,centerCrop=6
Public Sub setscaleType(v As View,st As Int)
	Dim jo As JavaObject=v
	jo.RunMethod("setScaleType",Array As Object(st))
End Sub
public Sub GetContext(obj As Object) As JavaObject
   Return GetBA(obj).GetField("context")
End Sub

Sub GetBA(obj As Object) As JavaObject
  Dim jo As JavaObject
  Dim cls As String = obj
  cls = cls.SubString("class ".Length)
  jo.InitializeStatic(cls)
  Return jo.GetFieldJO("processBA")
End Sub
'返回一个radiobutton或者null
Public Sub getSelectedRadioFromPanel(p As Panel) As RadioButton
	For Each v As RadioButton In p.GetAllViewsRecursive
		If v.Checked Then Return v
	Next
	Return Null
End Sub
public Sub setItemVal(p As Panel,val As String)
	Dim lbl As Label
	For Each v As View In p.GetAllViewsRecursive
		Log(v.Tag)
		If "val".EqualsIgnoreCase(v.Tag) Then
			lbl=v
			lbl.Text=val
		End If
	Next
	Return
End Sub
Private Sub initCityJsp
	If CityCurShen.IsInitialized Then Return
	Dim parser As JSONParser 
	CityCurShen.Initialize
	CityCurShen.lst.Initialize
	CityCurShen.name="新疆"
	parser.Initialize(g_store.getDef("cityjs","{data:[]}") )
	Dim root As Map = parser.NextObject 
	Dim data As List = root.Get("data") 
	For Each coldata As Map In data 
		Dim shi As CityShi
		shi.Initialize
		Dim parent_id As String = coldata.Get("parent_id") 
	    Dim region_id As String = coldata.Get("region_id") 
	    Dim region_name As String = coldata.Get("region_name") 
	    Dim children As List = coldata.Get("children") 
		shi.name=region_name
		shi.lst.Initialize
	    For Each colchildren As Map In children 
	        Dim parent_id As String = colchildren.Get("parent_id") 
	        Dim region_id As String = colchildren.Get("region_id") 
	        Dim region_name As String = colchildren.Get("region_name") 
			shi.lst.Add(region_name)
	    Next 
	    CityCurShen.lst.Add(shi)
	Next 
	Dim status As String = root.Get("status") 

	
End Sub
Public Sub getCurShen As CityShen
	initCityJsp
	Return CityCurShen
End Sub
'根据市名字获取区列表
public Sub getCityArr(shi As String) As CityShi
	initCityJsp
	Dim ts As CityShi
	For i=0 To CityCurShen.lst.Size-1
		ts=CityCurShen.lst.Get(i)
		If ts.name.EqualsIgnoreCase(shi) Then Exit
	Next
	Return ts
End Sub

'通用的方法
Public Sub AIO(act As Activity)
	SetEdtStyle(act,False)
End Sub
Public Sub SetEdtStyle(act As Panel,noPadding As Boolean)
	For Each v As View In act.GetAllViewsRecursive
		If GetType(v).ToLowerCase.Contains("panel")	 Then
			SetEdtStyle(v,noPadding)
		Else
			If GetType(v).ToLowerCase.Contains("edittext") Then
				SetEdtStyle2(v,noPadding)
			End If
		End If
	Next
End Sub
Public Sub SetEdtStyle2(edt As EditText,nopadding As Boolean)
	Dim cd As ColorDrawable
	cd.Initialize(Colors.White,5dip)
	edt.Background=cd
	If nopadding Then SetPadding(edt,0,0,0,0)
End Sub
Public Sub showTecDetail(tecid As Int)
	g_store.conf.Put("tecid",tecid)
	StartActivity(actTeacherDetail)
End Sub
Public Sub startWV(wvobj As wvUrl)
	If wvobj.IsInitialized Then
		g_store.conf.Put("wvurl",wvobj)
		StartActivity(actWebView)
	End If
End Sub
Public Sub ShowUrl(u As String)
	Dim wv As wvUrl
	wv.Initialize
	wv.Url=u
	g_store.conf.Put("wvurl",wv)
	StartActivity(actWebView)
End Sub
Public Sub ShowPic(u As String)
	Dim wv As pvObj
	wv.Initialize
	wv.Url=u
	ShowPic2(wv)
End Sub
Public Sub ShowPic2(pv As pvObj)
	CallSubDelayed2(actPhotoViewer,"showPic",pv)
End Sub
Sub ParseUri(s As String) As Object
    Dim r As Reflector
    Return r.RunStaticMethod("android.net.Uri", "parse", Array As Object(s), Array As String("java.lang.String"))                
End Sub
'设置fontawesome,支持button和label
Public Sub setFA(v As View,ico_name As String,extra As String)
	If Not(fa.IsInitialized) Then fa.Initialize
	If v Is Button Then
		Dim btn As Button=v
		btn.Typeface=fa.FontAwesomeTypeface
		btn.Text=fa.GetFontAwesomeIconByName(ico_name)&extra
	else if v Is RadioButton Then
		Dim rad As RadioButton=v
		rad.Typeface=fa.FontAwesomeTypeface
		rad.Text=fa.GetFontAwesomeIconByName(ico_name)&extra
	else if v Is Label Then
		Dim lbl As Label=v
		lbl.Typeface=fa.FontAwesomeTypeface
		lbl.Text=fa.GetFontAwesomeIconByName(ico_name)&extra
	End If
End Sub
Public Sub hideIme
	Dim ime As IME
	ime.Initialize("")
	ime.HideKeyboard
End Sub
'by RoundImage lib
'Public Sub getRoundImg(bmp As Bitmap) As Bitmap
'	Return ri.CreateBitmap(bmp)
'End Sub

#Region round image
'Public Sub getRoundImgRS(bmpin As Bitmap,corn As Float) As Bitmap
'	Return imgEff.RoundCorner(bmpin,corn)
'	
'End Sub
Public Sub  getSquareBmp(bmin As Bitmap,borderWidth1 As Int,borderColor1 As Int) As Bitmap
	Private clsBP As clsBitmapProcess
	If Not(clsBP.IsInitialized) Then clsBP.Initialize
	Return clsBP.getSquareBmp(bmin,borderWidth1,borderColor1)
End Sub
Public Sub  getRoundBmp(bmin As Bitmap,borderWidth1 As Int,borderColor1 As Int) As Bitmap
	Private clsBP As clsBitmapProcess
	If Not(clsBP.IsInitialized) Then clsBP.Initialize
	Return clsBP.getRoundBmp(bmin,borderWidth1,borderColor1)
End Sub
#end region
#Region 教师列表过滤
Public Sub showTecLst(parm As Map)
	
End Sub
#End Region
#Region api url
'
Public Sub getApi(idx As Int) As String
	Dim ret As String=S_APP_API
	Select idx
	Case apiIdx.APPBANNER
		ret=ret&"app/index/app_banner"
	Case apiIdx.KEMU
		ret=ret&"app/index/kemu"
	Case apiIdx.LOGIN
		ret=ret&"home/login/index"
	Case apiIdx.LOGOUT
		ret=ret&"home/login/logout"
	Case apiIdx.GETYHQ
		ret=ret&"home/index/member_yhj"
	Case apiIdx.REFUSHMYINFO
		ret=ret&"home/index"
	Case apiIdx.MYFAVTEACHER
		ret=ret&"home/index/gz_teach"
	Case apiIdx.DELFAVTEACHER
		ret=ret&"home/write/del_gz"
	Case apiIdx.SEARCHTEACHER
		ret=ret&"app/index/js_minute"
	Case apiIdx.MSTJ
		ret=ret&"app/index/js_tj_list"
	Case apiIdx.LOGINWITHSMS
		ret=ret&"home/login/sms_code_login"
	Case apiIdx.REQSMS
		ret=ret&"app/index/get_sms"
	Case apiIdx.REGISTER
		ret=ret&"app/register/zhuce"
	Case apiIdx.REQTEACHERDETAIL
		ret=ret&"app/index/js_xx"
	Case apiIdx.RESETPASSWORD
		ret=ret&"app/register/reset_one"
	Case apiIdx.FEEDBACK
		ret=ret&"app/updata/feed"
	Case apiIdx.ADDYHQ
		ret=ret&"home/write/up_yhj"
	Case apiIdx.REQJINQI
		ret=ret&"app/index/banner_list"
	Case apiIdx.UPLOADIMG
		ret=ret&"home/index/upload"
	Case apiIdx.MODIFYMYINFO
		ret=ret&"home/write/index"
	Case apiIdx.MODIFYPASS
		ret=ret&"home/write/member_pwd"
	Case apiIdx.ADDFAVTEACHER
		ret=ret&"home/write/add_gz"
	Case apiIdx.REQKECHENLIST
		ret=ret&"home/index/member_kechen"
	Case apiIdx.REQORDLST
		ret=ret&"home/index/member_order"
	Case apiIdx.REQCAIWULST
		ret=ret&"home/MyMoney/member_money_io"
	Case apiIdx.REQMYRATE
		ret=ret&"home/index/member_pl"
	Case apiIdx.SUBMITORDER
		ret=ret&"home/orderdata/order"
	Case apiIdx.REQINAPPPAY
		ret=ret&"home/orderdata/order_pay"
	Case apiIdx.REQPAYPWDCHG
		ret=ret&"home/MyMoney/up_pay_pwd"
	Case apiIdx.REQUNRATENUM
		ret=ret&"home/index/cha_pl"
	Case apiIdx.REQJQLST
		ret=ret&"home/index/member_jinqi"
	Case apiIdx.REQCHARGE1
		ret=ret&"home/MyMoney/chongzhi"
	Case apiIdx.REQCHARGE2
		ret=ret&"home/MyMoney/dinpay"
	Case apiIdx.REQORDDETAIL
		ret=ret&"home/index/member_order_view"
	Case apiIdx.REQORDERREFUND
		ret=ret&"home/orderdata/order_paytk"
	Case apiIdx.POSTRATE
		ret=ret&"home/write/commit"
	Case apiIdx.REQALLKCLISTBYTEACHER
		ret=ret&"app/index/kc_list"
	Case apiIdx.SUBJINQIORDER
		ret=ret&"home/orderdata/jq_order"
	Case apiIdx.REQEVALLISTBYTEACHER
		ret=ret&"app/index/pl"
	Case apiIdx.REQTEACHERLIST
		ret=ret&"app/index/js_list"
	Case apiIdx.REQCITYLIST
		ret=ret&"app/index/city"
	Case apiIdx.REQLOGINBYTHIRD
		ret=ret&"home/login/san_code_login"
	Case apiIdx.REQBINDTHIRDACCOUNT
		ret=ret&"home/write/bding"
	Case apiIdx.REQUNCOMPLETEKC
		ret=ret&"home/index/member_kechen"
	Case apiIdx.REQALLFUDAOBAN
		ret=ret&"app/index/kc_list?kc_type=3"
	Case apiIdx.REQHELPYOUFINDTEACHER
		ret=ret&"app/updata/bang_zhao_teach"
	Case apiIdx.REQNEWSLIST
		ret=ret&"app/qita"
	End Select
	Log("getApi:"&idx&" "&ret)
	Return ret
End Sub
Public Sub sharestr(str As String)
	Dim i As Intent
	i.Initialize(i.ACTION_SEND,"")
	i.PutExtra("android.intent.extra.TEXT",str)
	i.SetType("text/plain")
	i.WrapAsIntentChooser("分享")
	StartActivity(i)
End Sub
Public Sub calltel(tel As String)
	Dim i As Intent
	If tel.ToLowerCase.StartsWith("tel:")=False Then tel="tel:"&tel.ToLowerCase
	i.Initialize(i.ACTION_VIEW,tel)
	StartActivity(i)
End Sub
public Sub combinPic(pic As String) As String
	If pic.ToLowerCase.StartsWith("http") Then Return pic
	Dim ret As String=S_TESTMYHEADER
	If pic.Length>0 Then
		ret=S_APP_API
		ret=ret.Replace("app/","")
		ret=ret&pic
	End If
	Return ret
End Sub
Public Sub isLogin As Boolean
	Return g_store.conf.GetDefault("islogin",False)
End Sub
Public Sub getShareSdkCfgList As List
	If lstShareSdkCfg.IsInitialized And lstShareSdkCfg.Size>0 Then Return lstShareSdkCfg
	lstShareSdkCfg.Initialize
	Dim m As Map
	m.Initialize
	m.Put("pname","Wechat")
	m.Put("Id","1")
	m.Put("SortId","1")
	m.Put("AppId","wx98b3b7e7c8ff810e")
	m.Put("AppSecret","e008c0e847a2109278cb930b0248e6ca")
	m.Put("BypassApproval","true")
	m.Put("Enable","true")
	lstShareSdkCfg.Add(m)
	Dim m As Map
	m.Initialize
	m.Put("pname","WechatMoments")
	m.Put("Id","2")
	m.Put("SortId","2")
	m.Put("AppId","wx98b3b7e7c8ff810e")
	m.Put("AppSecret","e008c0e847a2109278cb930b0248e6ca")
	m.Put("BypassApproval","true")
	m.Put("Enable","true")
	lstShareSdkCfg.Add(m)
	Dim m As Map
	m.Initialize
	m.Put("pname","WechatFavorite")
	m.Put("Id","3")
	m.Put("SortId","3")
	m.Put("AppId","wx98b3b7e7c8ff810e")
	m.Put("AppSecret","e008c0e847a2109278cb930b0248e6ca")
	m.Put("Enable","true")
	lstShareSdkCfg.Add(m)
	Dim m As Map
	m.Initialize
	m.Put("pname","QQ")
	m.Put("Id","4")
	m.Put("SortId","4")
	m.Put("AppId","1105237749")
	m.Put("AppKey","UCkTh71GMn6xYPpe")
	m.Put("ShareByAppClient","true")
	m.Put("Enable","true")
	lstShareSdkCfg.Add(m)
	Dim m As Map
	m.Initialize
	m.Put("pname","ShortMessage")
	m.Put("Id","5")
	m.Put("SortId","5")
	m.Put("Enable","true")
	lstShareSdkCfg.Add(m)
	Return lstShareSdkCfg
End Sub
#End Region